package com.gagakuai.bpm.utils;


import com.gagakuai.bpm.domian.dto.camunda.UserInfo;
import org.springframework.core.NamedInheritableThreadLocal;


public class UserUtil {

    private static final NamedInheritableThreadLocal<UserInfo> USER_INFO = new NamedInheritableThreadLocal<>("userInfo");
    private static final NamedInheritableThreadLocal<String> TOKEN_STRING = new NamedInheritableThreadLocal<>("token");

    public static void set(UserInfo userInfo) {
        USER_INFO.set(userInfo);
    }

    public static void setToken(String token) {
        TOKEN_STRING.set(token);
    }

    public static void removeToken() {
        TOKEN_STRING.remove();
    }

    public static void remove() {
        USER_INFO.remove();
    }

    public static UserInfo get() {
        return USER_INFO.get();
    }

    public static String getToken() {
        return TOKEN_STRING.get();
    }

}
